package ee.ttu.agent.smartHouse.services;

import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import ee.ttu.agent.smartHouse.agent.SupervisorAgent;
import ee.ttu.agent.smartHouse.gui.SupervisorAgentGui;
import ee.ttu.agent.smartHouse.util.CustomACLMessage;

public class SupervisorBehaviour extends CyclicBehaviour {

	private static final long serialVersionUID = -7193528552785527280L;
	private SupervisorAgent supervisorAgent;

	public SupervisorBehaviour(SupervisorAgentGui referencedGui, SupervisorAgent supervisorAgent) {
		this.supervisorAgent = supervisorAgent;
	}

	@Override
	public void action() {
		ACLMessage msg = myAgent.receive();
		if (msg != null) {
			
			//online interaction request
			if(msg.getPerformative() == CustomACLMessage.FROM_USER){
				String fromUser = msg.getContent();
				supervisorAgent.setMessage(fromUser);
			}

		} else {
			block();
		}
	}

}
